Login
Days of Year
Options
Days of Year
Choose Query
Days Of Year.sql
Admin/SampleApi.sql
Admin/Logins.sql
Admin/EditLogin.sql
AdventureWorks/fsp_Test.sql
AdventureWorks/ListProducts.sql
AdventureWorks/ProductPriceHistory.sql
Show all of the days this year categorized by month, highlighting Friday of each week
StartDate
date
EndDate
date
Actions
View
Reset
Directories
Home
Admin/
AdventureWorks/
Source
-- Title: Days of Year -- Description: Show all of the days this year categorized by month, highlighting Friday of each week -- ButtonLabel: View -- ButtonClass: btn-success -- ButtonIcon: fa-eye -- SaveTo: /run/save.sql -- SaveColumns: MonthName,DayOfWeek -- ShowSource: 1 declare @StartDate date = ?; -- Default: {{ Date: first day of january this year }} declare @EndDate date = ?; -- Default: {{ Date: last day of december this year }} declare @Cursor date = @StartDate; drop table if exists #days; select getdate() as ExactDate, cast('' as varchar(100)) as MonthName, cast('' as varchar(100)) as DayOfWeek into #days; delete from #days; while @Cursor <= @EndDate begin insert into #days select @Cursor as ExactDate, datename(month, @Cursor) as MonthName, datename(weekday, @Cursor) as DayOfWeek; set @Cursor = dateadd(day, 1, @Cursor); end; select d.MonthName as __Section, case when d.DayOfWeek like 'Friday' then 'text-success fw-bold' when d.DayOfWeek like 'Monday' then 'text-danger fw-bold' else '' end as __NextCellClass1, d.DayOfWeek, d.MonthName, datepart(day, d.ExactDate) as DayOfMonth, case when cast(d.ExactDate as date) = cast(getdate() as date) then 'bg-warning text-black' else '' end as __RowClass, d.ExactDate, 1.0 + floor(100 * rand(convert(varbinary, newid()))) as RandomNum from #days as d;